home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Disc to the Future 2
/
Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin
/
MAC
/
MPW_TOOL
/
TOOLS
/
TOOLS_WI
/
PERL
/
UNTESTED
/
EG
/
VAN
/
EMPTY
next >
Wrap
Text File
|
1991-04-28
|
785b
|
46 lines
#!/usr/bin/perl
# $Header: empty,v 4.0 91/03/20 01:15:25 lwall Locked $
# This script empties a trashcan.
$recursive = shift if $ARGV[0] eq '-r';
@ARGV = '.' if $#ARGV < 0;
chop($pwd = `pwd`);
dir: foreach $dir (@ARGV) {
unless (chdir $dir) {
print stderr "Can't find directory $dir: $!\n";
next dir;
}
if ($recursive) {
do cmd('find . -name .deleted -exec /bin/rm -rf {} ;');
}
else {
if (-d '.deleted') {
do cmd('rm -rf .deleted');
}
else {
if ($dir eq '.' && $pwd =~ m|/\.deleted$|) {
chdir '..';
do cmd('rm -rf .deleted');
}
else {
print stderr "No trashcan found in directory $dir\n";
}
}
}
}
continue {
chdir $pwd;
}
# force direct execution with no shell
sub cmd {
system split(' ',join(' ',@_));
}